//
//  CollectionViewBaseCell.swift
//  CWLiving
//
//  Created by 方正刚 on 2017/7/9.
//  Copyright © 2017年 方正刚. All rights reserved.
//

import UIKit

class CollectionViewBaseCell: UICollectionViewCell {
    @IBOutlet weak var imageView: UIImageView!
    @IBOutlet weak var nickNameLabel: UILabel!
    @IBOutlet weak var onLineBtn: UIButton!
    
    var achor: AnchorModel? {
        didSet {
            
            /// 校验模型是否有值
            guard let anchor = achor else {
                return
            }
            
            /// 显示在线人数
            var onlineString: String = ""
            
            if anchor.online >= 10000 {
                
                onlineString = "\(anchor.online / 10000)万在线"
            }else {
                onlineString = "\(anchor.online)在线"
                
            }
            
            onLineBtn.setTitle(onlineString, for: .normal)
            
            /// 显示昵称
            nickNameLabel.text = anchor.nickname
            
            
            /// 显示封面图片
            guard let iconURL = NSURL(string: anchor.vertical_src) else {return}
            
            
            imageView.kf.setImage(with: iconURL as URL,  placeholder: UIImage(named: "live_cell_default_phone"))
        }
    }

}
